﻿<%@ Page Title="Edit Festivals" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Edit.aspx.cs" Inherits="Groep8.Edit_Festivals.Edit" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxToolkit" %> 

<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <style> 
        td input {
            width: auto;
        }
    </style>
    <h2>Add,Edit/Delete Festivals</h2>

    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="fest_id" DataSourceID="SqlDataSource1" BorderStyle="Solid" BorderWidth="1px" CellPadding="4" ForeColor="#333333" GridLines="None" Width="960px">
        <AlternatingRowStyle BackColor="White" />
        <Columns>
            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
            <asp:BoundField DataField="fest_id" HeaderText="fest_id" InsertVisible="False" ReadOnly="True" SortExpression="fest_id" Visible="False" />
            <asp:BoundField DataField="fest_naam" HeaderText="Name" SortExpression="fest_naam" />
            <asp:BoundField DataField="fest_locatie" HeaderText="Location" SortExpression="fest_locatie" />
            <asp:BoundField DataField="fest_datum" HeaderText="Date" SortExpression="fest_datum" />
            <asp:BoundField DataField="fest_duur" HeaderText="Duration" SortExpression="fest_duur" />
            <asp:BoundField DataField="fest_country" HeaderText="Country" SortExpression="fest_country" />
        </Columns>
        <EditRowStyle BackColor="#2461BF" HorizontalAlign="Center"/>
        <FooterStyle BackColor="#3A8DC7" Font-Bold="True" ForeColor="White" BorderStyle="Solid" BorderWidth="1px" HorizontalAlign="Center"/>
        <HeaderStyle BackColor="#3A8DC7" Font-Bold="True" ForeColor="White" BorderStyle="Solid" BorderColor="Black" BorderWidth="1px" HorizontalAlign="Center" Height="50px" Font-Size="18px"/>
        <PagerStyle BackColor="#3A8DC7"  Font-Bold="True" ForeColor="White" BorderStyle="Solid" BorderWidth="1px" HorizontalAlign="Center"/>
        <RowStyle BackColor="#EFF3FB" HorizontalAlign="Center"  Font-Size="14px" Width="960px" Height="50px" />
        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" HorizontalAlign="Center"/>
        <SortedAscendingCellStyle BackColor="#F5F7FB" />
        <SortedAscendingHeaderStyle BackColor="#6D95E1" />
        <SortedDescendingCellStyle BackColor="#E9EBEF" />
        <SortedDescendingHeaderStyle BackColor="#4870BE" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DefaultConnection %>" DeleteCommand="DeleteFestivals" DeleteCommandType="StoredProcedure" InsertCommand="InsertFestivals" InsertCommandType="StoredProcedure" SelectCommand="SelectFestivals" SelectCommandType="StoredProcedure" UpdateCommand="UpdateFestivals" UpdateCommandType="StoredProcedure">
        <DeleteParameters>
            <asp:Parameter Name="fest_id" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="fest_naam" Type="String" />
            <asp:Parameter Name="fest_locatie" Type="String" />
            <asp:Parameter DbType="Date" Name="fest_datum" />
            <asp:Parameter Name="fest_duur" Type="Int32" />
            <asp:Parameter Name="fest_country" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="fest_id" Type="Int32" />
            <asp:Parameter Name="fest_naam" Type="String" />
            <asp:Parameter Name="fest_locatie" Type="String" />
            <asp:Parameter DbType="Date" Name="fest_datum" />
            <asp:Parameter Name="fest_duur" Type="Int32" />
            <asp:Parameter Name="fest_country" Type="String" />
        </UpdateParameters>
    </asp:SqlDataSource>

    <br>
    <h2>Add festival</h2> 
    
    <p class="message-info">
        All fields are required!<br />
        <%= Message %>
    </p>

    <p class="validation-summary-errors">
        <asp:Literal runat="server" ID="ErrorMessage" />
    </p>

    <fieldset>
        <legend>Registration Form</legend>
        <ol>
            <li>
                <asp:Label ID="Label1" runat="server" AssociatedControlID="FestivalName">Festival name</asp:Label>
                <asp:TextBox runat="server" ID="FestivalName" />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="FestivalName"
                    CssClass="field-validation-error" ErrorMessage="The name field is required." />
            </li>
            <li>
                <asp:Label ID="Label2" runat="server" AssociatedControlID="Location">Location</asp:Label>
                <asp:TextBox runat="server" ID="Location" />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="Location"
                    CssClass="field-validation-error" ErrorMessage="The name field is required." />
            </li>
            <li>
                <asp:Label ID="Label3" runat="server" AssociatedControlID="Country">Country</asp:Label>
                <asp:TextBox runat="server" ID="Country" />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="Country"
                    CssClass="field-validation-error" ErrorMessage="The name field is required." />
            </li>
            <li>
                <asp:Label ID="Label4" runat="server" AssociatedControlID="Country">Duration</asp:Label>
                <asp:TextBox runat="server" ID="Duration" />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="Duration"
                    CssClass="field-validation-error" ErrorMessage="The name field is required." />
                <asp:CompareValidator ID="cv" runat="server" ControlToValidate="Duration" Type="Integer"
                    Operator="DataTypeCheck" CssClass="field-validation-error" ErrorMessage="Value must be an integer!" />
            </li>
            <li>
                <asp:Label ID="Label5" runat="server" AssociatedControlID="Country">Date</asp:Label>
                <asp:TextBox runat="server" ID="Date" />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="Date"
                    CssClass="field-validation-error" ErrorMessage="The name field is required." />
                <ajaxToolkit:CalendarExtender ID="CalendarExtender1" TargetControlID="Date" runat="server" Format="yyyy-MM-dd"/> 
                <asp:RegularExpressionValidator ID="regDate" runat="server" ValidationExpression="[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]" ControlToValidate="Date"
                     CssClass="field-validation-error" ErrorMessage="Value must be a date (yyyy-mm-dd)!" SetFocusOnError="True" />
            </li>
        </ol>
        <asp:Button ID="Button1" runat="server" CommandName="MoveNext" Text="Add festival" onClick="AddFestival" />
    </fieldset>
</asp:Content>